<template>
  <div>
    <!--    搜索栏-->
    <el-row class="table-grid-content">
      <el-col :span="24" class="grid">
        <el-input v-model="input" placeholder="请输入搜索关键字"></el-input>
      </el-col>
    </el-row>
    <!--    头部命名-->
    <el-table
      :data="table"
      border
      style="width: 100%"
      max-height="578px">
      <el-table-column
        align="center"
        prop="usersName"
        label="姓名">
      </el-table-column>
      <el-table-column
        align="center"
        prop="userClass"
        label="班级">
      </el-table-column>
      <el-table-column
        align="center"
        prop="usersId"
        label="学号">
      </el-table-column>
      <el-table-column
        align="center"
        prop="gameName"
        label="加分原因">
      </el-table-column>
      <el-table-column
        align="center"
        prop="score"
        label="加分分数">
      </el-table-column>
      <el-table-column
        align="center"
        prop="addtype"
        label="加分类型">
      </el-table-column>
<!--      <el-table-column-->
<!--        align="center"-->
<!--        prop="date"-->
<!--        label="日期">-->
<!--      </el-table-column>-->
    </el-table>
    <!--    分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="10"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalCount">
    </el-pagination>
  </div>
</template>

<style scoped>
.table-grid-content {
  border-radius: 8px;
  height: 50px;
  background: #ebeef5;
  padding: 5px;
  margin: 0;
}
</style>

<script>
import axios from "_axios@0.26.1@axios";

export default {
  name:'ElseGamePublicity',

  mounted() {
    //页面加载完成后异步请求查询所有数据
    this.selectAll();
  },

  methods: {
    //查询所有函数
    selectAll() {
      axios.get('/api/awarded/publicityOfOtherCompetitions?page='+ this.currentPage + "&&rows=" + this.pageSize).then((res) => {

        //设置表格数据
        this.tables = res.data.data.dataList;

        //设置总记录数
        this.totalCount = res.data.data.rows;
      })
    },
    //分页功能
    handleSizeChange(val) {
      //重新设置每页显示的条数
      this.pageSize = val;
      this.selectAll();
    },
    handleCurrentChange(val) {
      //重新设置当前页码
      this.currentPage = val;
      this.selectAll();
    },
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },
    goBack() {
      console.log('go back');
    },
  },
  computed: {
    table() {
      const input = this.input
      if (input) {
        return this.tables.filter(data => {
          return Object.keys(data).some(key => {
            return String(data[key]).toLowerCase().indexOf(input) > -1
          })
        })
      }
      return this.tables
    }
  },
  data() {
    return {
      msg: 'Welcome to Your Vue.js App',
      centerDialogVisible: false,
      isAddMembers: false,
      searchData: '',
      input: '',
      id:'',

      //当前页码
      currentPage: 1,
      //每页显示条数
      pageSize: 10,
      //总记录数
      totalCount: 100,

      tables: []
    }
  }
}
</script>

